package cn.njyd.corejava.thread.myday01;


class TicketRunnable implements Runnable{
    int num = 50;
    @Override
    public void run() {
        while(true){
            if (num>0) {
                System.out.println(Thread.currentThread().getName() + "卖了一张票,还剩[" + (--num) + "]张票");
            } else {
                System.out.println("票已卖完");
                break;
            }
        }
    }
}



public class MyThread03 {


    public static void main(String[] args) {
        TicketRunnable tr = new TicketRunnable();
        Thread t1 = new Thread(tr,"南京南");
        Thread t2 = new Thread(tr,"南京北");
        Thread t3 = new Thread(tr,"南京站");
        t1.start();
        t2.start();
        t3.start();
    }
}
